<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>RSA 加解密</title>
    <script type="text/javascript" th:src="@{~/js/jquery-3.0.0.min.js}"></script>
    <script type="text/javascript" th:src="@{~/js/jsencrypt.min.js}"></script>
</head>
<body>

<script type="text/javascript">
    $(function() {
        $("#bt").click(
            function() {

                var encrypt = new JSEncrypt();
                encrypt.setPublicKey($("#publickey").val());
                $.ajax({
                    type: "POST",
                    url:"/rsaTest",
                    data:"{\"requestData\":"+encrypt.encrypt(JSON.stringify({name:"123456"}))+"}",
                    dataType:'json',
                    contentType: "application/json",
                    success: function(result) {
                        alert("解密的名称：" + uncrypted);
                    }
                });
            });
    });
</script>
<h2>公钥：</h2>
<textarea id="publickey" rows="5" cols="45">MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDhvDvCYirEgNh9K/6GvcbK3Ayv5jOrPZMNDFw5oT8PdGNrGkxeIW/be8DN3LX8SWSSt00kUCr1/AuVh8Qxb7myibNbA6p3ysKmqV/Q6XetcO2aUJVXz5aFevm6tZWggo65/I/dKHqLCBubVfQCtELw0jhJNf09b89FbBKoxug2IwIDAQAB
        </textarea>
<input type="button" id="bt" value="提交" />
</body>
</html>